#include "fxcc/yml/Serializer.h"

using namespace fxcc::yml;

template <>
void Serializer::Encode<glm::quat>(YAML::Node& node, const glm::quat& inst)
{
    SetVariable<float>(node, "x", inst.x);
    SetVariable<float>(node, "y", inst.y);
    SetVariable<float>(node, "z", inst.z);
    SetVariable<float>(node, "w", inst.w);
};

template <>
bool Serializer::Decode<glm::quat>(const YAML::Node& node, glm::quat& inst)
{
    GetVariable<float>(node, "x", inst.x);
    GetVariable<float>(node, "y", inst.y);
    GetVariable<float>(node, "z", inst.z);
    GetVariable<float>(node, "w", inst.w);
    return true;
}


template <>
void Serializer::Encode<glm::vec3>(YAML::Node& node, const glm::vec3& inst)
{
    SetVariable<float>(node, "x", inst.x);
    SetVariable<float>(node, "y", inst.y);
    SetVariable<float>(node, "z", inst.z);
};

template <>
bool Serializer::Decode<glm::vec3>(const YAML::Node& node, glm::vec3& inst)
{
    GetVariable<float>(node, "x", inst.x);
    GetVariable<float>(node, "y", inst.y);
    GetVariable<float>(node, "z", inst.z);
    return true;
}

template <>
void Serializer::Encode<glm::vec4>(YAML::Node& node, const glm::vec4& inst)
{
    SetVariable<float>(node, "x", inst.x);
    SetVariable<float>(node, "y", inst.y);
    SetVariable<float>(node, "z", inst.z);
    SetVariable<float>(node, "w", inst.w);
};

template <>
bool Serializer::Decode<glm::vec4>(const YAML::Node& node, glm::vec4& inst)
{
    GetVariable<float>(node, "x", inst.x);
    GetVariable<float>(node, "y", inst.y);
    GetVariable<float>(node, "z", inst.z);
    GetVariable<float>(node, "w", inst.w);
    return true;
}
template <>
void Serializer::Encode<glm::vec2>(YAML::Node& node, const glm::vec2& inst)
{
    SetVariable<float>(node, "x", inst.x);
    SetVariable<float>(node, "y", inst.y);
};

template <>
bool Serializer::Decode<glm::vec2>(const YAML::Node& node, glm::vec2& inst)
{
    GetVariable<float>(node, "x", inst.x);
    GetVariable<float>(node, "y", inst.y);
    return true;
}

template <>
void Serializer::Encode<glm::ivec4>(YAML::Node& node, const glm::ivec4& inst)
{
    SetVariable<int>(node, "x", inst.x);
    SetVariable<int>(node, "y", inst.y);
    SetVariable<int>(node, "z", inst.z);
    SetVariable<int>(node, "w", inst.w);
};

template <>
bool Serializer::Decode<glm::ivec4>(const YAML::Node& node, glm::ivec4& inst)
{
    GetVariable<int>(node, "x", inst.x);
    GetVariable<int>(node, "y", inst.y);
    GetVariable<int>(node, "z", inst.z);
    GetVariable<int>(node, "w", inst.w);
    return true;
}


template <>
void Serializer::Encode<glm::ivec3>(YAML::Node& node, const glm::ivec3& inst)
{
    SetVariable<int>(node, "x", inst.x);
    SetVariable<int>(node, "y", inst.y);
    SetVariable<int>(node, "z", inst.z);
};

template <>
bool Serializer::Decode<glm::ivec3>(const YAML::Node& node, glm::ivec3& inst)
{
    GetVariable<int>(node, "x", inst.x);
    GetVariable<int>(node, "y", inst.y);
    GetVariable<int>(node, "z", inst.z);
    return true;
}

template <>
void Serializer::Encode<glm::ivec2>(YAML::Node& node, const glm::ivec2& inst)
{
    SetVariable<int>(node, "x", inst.x);
    SetVariable<int>(node, "y", inst.y);
};

template <>
bool Serializer::Decode<glm::ivec2>(const YAML::Node& node, glm::ivec2& inst)
{
    GetVariable<int>(node, "x", inst.x);
    GetVariable<int>(node, "y", inst.y);
    return true;
}